fix: narrow exceptions in get_speckit_version() from Exception to specific types - #3917
Open
Quratulain-bilal wants to merge 1 commit into
Open
fix: narrow exceptions in get_speckit_version() from Exception to specific types#3917Quratulain-bilal wants to merge 1 commit into
Quratulain-bilal wants to merge 1 commit into
Conversation
…cific types Outer catch narrowed to PackageNotFoundError (the only expected failure from importlib.metadata.version). Inner catch narrowed to (OSError, ValueError, KeyError) for file/parse errors.
Contributor
There was a problem hiding this comment.
Pull request overview
Narrows version-resolution exception handling to expected metadata, file, and TOML parsing failures.
Changes:
- Handles missing package metadata explicitly.
- Limits pyproject fallback errors to specific exception types.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/_assets.py |
Narrows exceptions in get_speckit_version(). |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Balanced
| except Exception: | ||
| # Intentionally ignore any errors while reading/parsing pyproject.toml. | ||
| # If this lookup fails for any reason, we fall back to returning "unknown" below. | ||
| except (OSError, ValueError, KeyError): |
| try: | ||
| return importlib.metadata.version("specify-cli") | ||
| except Exception: | ||
| except importlib.metadata.PackageNotFoundError: |
mnriem
requested changes
Aug 11, 2026
mnriem
left a comment
Collaborator
There was a problem hiding this comment.
Please address Copilot feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Outer catch narrowed to
PackageNotFoundError. Inner catch narrowed to(OSError, ValueError, KeyError)for file/parse errors.Fix
Narrowed both exception handlers to specific types.
Testing